
package logical_spaces.beans;

import java.io.Serializable;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpSession;
import static logical_spaces.DAO.TableSpaceDAO.conn;
import logical_spaces.business.TableSpaceBusiness;
import login.beans.ConectionBean;

/**
 *
 * @author jhtobav
 */
@ManagedBean
@RequestScoped
public class CreateTableSpaceBeanTemporary implements Serializable{
 
    private String tableSpaceName;
    private String tableSpaceSize;
    private String tableSizeOption;
    private String uniformSizeOption;
    private String tableFileName;
    private String radioFileSizeValue;
    private String radioTableStateValue;
    private String radioUniformSizeValue;
    private String uniformSizeSpinnerValue;
    private String radioAutoExtendValue;
    private String incrementoSizeOptions;
    private String maxSizeOptions;
    private String autoExtendSpinnerIncrementoValue;
    private String autoExtendSpinnerMaxSizeValue;
    private String mensaje;

    public CreateTableSpaceBeanTemporary() {
        
        tableSizeOption = "K";
        uniformSizeOption = "K";
        incrementoSizeOptions = "K";
        maxSizeOptions = "K";
        radioUniformSizeValue = "radio2opt1";
        
    }

    public String getTableSpaceName() {
        return tableSpaceName;
    }

    public void setTableSpaceName(String tableSpaceName) {
        this.tableSpaceName = tableSpaceName;
    }

    public String getTableSpaceSize() {
        return tableSpaceSize;
    }

    public void setTableSpaceSize(String tableSpaceSize) {
        this.tableSpaceSize = tableSpaceSize;
    }

    public String getTableSizeOption() {
        return tableSizeOption;
    }

    public void setTableSizeOption(String tableSizeOption) {
        this.tableSizeOption = tableSizeOption;
    }

    public String getUniformSizeOption() {
        return uniformSizeOption;
    }

    public void setUniformSizeOption(String uniformSizeOption) {
        this.uniformSizeOption = uniformSizeOption;
    }

    public String getTableFileName() {
        return tableFileName;
    }

    public void setTableFileName(String tableFileName) {
        this.tableFileName = tableFileName;
    }

    public String getRadioFileSizeValue() {
        return radioFileSizeValue;
    }

    public void setRadioFileSizeValue(String radioFileSizeValue) {
        this.radioFileSizeValue = radioFileSizeValue;
    }

    public String getRadioTableStateValue() {
        return radioTableStateValue;
    }

    public void setRadioTableStateValue(String radioTableStateValue) {
        this.radioTableStateValue = radioTableStateValue;
    }

    public String getRadioUniformSizeValue() {
        return radioUniformSizeValue;
    }

    public void setRadioUniformSizeValue(String radioUniformSizeValue) {
        this.radioUniformSizeValue = radioUniformSizeValue;
    }

    public String getUniformSizeSpinnerValue() {
        return uniformSizeSpinnerValue;
    }

    public void setUniformSizeSpinnerValue(String uniformSizeSpinnerValue) {
        this.uniformSizeSpinnerValue = uniformSizeSpinnerValue;
    }

    public String getRadioAutoExtendValue() {
        return radioAutoExtendValue;
    }

    public void setRadioAutoExtendValue(String radioAutoExtendValue) {
        this.radioAutoExtendValue = radioAutoExtendValue;
    }

    public String getIncrementoSizeOptions() {
        return incrementoSizeOptions;
    }

    public void setIncrementoSizeOptions(String incrementoSizeOptions) {
        this.incrementoSizeOptions = incrementoSizeOptions;
    }

    public String getMaxSizeOptions() {
        return maxSizeOptions;
    }

    public void setMaxSizeOptions(String maxSizeOptions) {
        this.maxSizeOptions = maxSizeOptions;
    }

    public String getAutoExtendSpinnerIncrementoValue() {
        return autoExtendSpinnerIncrementoValue;
    }

    public void setAutoExtendSpinnerIncrementoValue(String autoExtendSpinnerIncrementoValue) {
        this.autoExtendSpinnerIncrementoValue = autoExtendSpinnerIncrementoValue;
    }

    public String getAutoExtendSpinnerMaxSizeValue() {
        return autoExtendSpinnerMaxSizeValue;
    }

    public void setAutoExtendSpinnerMaxSizeValue(String autoExtendSpinnerMaxSizeValue) {
        this.autoExtendSpinnerMaxSizeValue = autoExtendSpinnerMaxSizeValue;
    }

    public String getMensaje() {
        return mensaje;
    }

    public void setMensaje(String mensaje) {
        this.mensaje = mensaje;
    }
    
    public void createTableSpace(){
        
        System.out.println("NOMBRE -> " + tableSpaceName);
        System.out.println("SIZE -> " + tableSpaceSize);
        System.out.println("FILE NAME -> " + tableFileName);
        System.out.println("TAMANO ARCHIVO -> " + radioFileSizeValue);
        System.out.println("UNIFORM SIZE VALUE -> " + uniformSizeSpinnerValue);
        System.out.println("UNIFORM SIZE -> " + radioUniformSizeValue);
        System.out.println("AUTOEXTEND -> " + radioAutoExtendValue);
        
        FacesContext context = javax.faces.context.FacesContext.getCurrentInstance();
        
        HttpSession session = (HttpSession) context.getExternalContext().getSession(false);
        ConectionBean conectionBean =(ConectionBean) session.getAttribute("conectionBean");

        conn = conectionBean.currentConnection;
        
        TableSpaceBusiness tableSpaceBusiness = new TableSpaceBusiness( conn );
        
        mensaje = tableSpaceBusiness.createTableSpaceTemporary(tableSpaceName, tableSpaceSize, tableSizeOption, tableFileName , radioFileSizeValue, radioUniformSizeValue, uniformSizeSpinnerValue, uniformSizeOption, radioAutoExtendValue, autoExtendSpinnerIncrementoValue, autoExtendSpinnerMaxSizeValue, incrementoSizeOptions, maxSizeOptions);
        
        System.out.println("ghfhg"+mensaje+"ghfhg");
        context.addMessage(null, new FacesMessage("INFORMACION",mensaje));
    }
    
}
  